package com.boot.ys.mybatisplus.service.impl;

import com.boot.ys.mybatisplus.entity.Easyexcel;
import com.boot.ys.mybatisplus.mapper.EasyexcelMapper;
import com.boot.ys.mybatisplus.service.EasyexcelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boot.ys.mybatisplus.utils.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Yang Sheng
 * @since 2022-02-11
 */
@Service
public class EasyexcelServiceImpl extends ServiceImpl<EasyexcelMapper, Easyexcel> implements EasyexcelService {

    @Autowired
    private EasyexcelMapper easyexcelMapper;

    //导出 EasyExcel(方式)
    @Override
    public void exportEasyExcel(HttpServletResponse response) {
        try {
            List<Easyexcel> easyexcels = easyexcelMapper.selectList(null);
            ExcelUtils.export2Web(response,"用户表","用户信息",Easyexcel.class,easyexcels);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
